package com.cxy.datawarehouse.controller;

import com.cxy.datawarehouse.entity.StandardCodeType;
import com.cxy.datawarehouse.biz.StandardCodeTypeBiz;
import com.cxy.datawarehouse.entity.User;
import com.cxy.datawarehouse.response.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags="标准代码类别")
@RestController
@Validated
@Slf4j
@RequestMapping("/standardCodeType")
public class StandardCodeTypeController {
    @Resource
    StandardCodeTypeBiz standardCodeTypeBiz;

    @GetMapping(value = "/list")
    @ApiOperation("标准代码类别列表")
    public Result<List<StandardCodeType>> list() {
        List<StandardCodeType> list = standardCodeTypeBiz.list();
        return Result.ok(list);
    }

    @PostMapping(value = "/create")
    @ApiOperation("创建标准代码类别")
    public Result<Long> create(@RequestBody StandardCodeType standardCodeType) {
        standardCodeTypeBiz.create(standardCodeType);
        return Result.ok();
    }

    @PostMapping(value = "/update")
    @ApiOperation("修改标准代码类别")
    public Result<Long> update(@RequestBody StandardCodeType standardCodeType) {
        standardCodeTypeBiz.update(standardCodeType);
        return Result.ok();
    }

    @PostMapping(value = "/deleteById/{id}")
    @ApiOperation("删除标准代码类别")
    public Result<Long> deleteById(@PathVariable Long id) {
        standardCodeTypeBiz.deleteById(id);
        return Result.ok();
    }
}
